package de.se.ludoapp;

import android.app.Application;
import de.se.ludoapp.gaming.Game;
import de.se.ludoapp.gaming.LudoSystem;
import de.se.ludoapp.gaming.PlayerType;
import de.se.ludoapp.gaming.User;

/**
 * LudoApplication bundle all information of the application.
 * 
 * @author Marlen Rotert
 * 
 */
public class LudoApplication extends Application {

	private User logedinUser;

	private Game currentGame;

	private LudoSystem ludoStub;

	public User getlogedinUser() {
		return logedinUser;
	}

	public void setLogedinUser(User logedinUser) {
		this.logedinUser = logedinUser;
	}

	public LudoSystem getLudoStub() {
		return ludoStub;
	}

	public void setLudoStub(LudoSystem ludoStub) {
		this.ludoStub = ludoStub;
	}

	public Game getCurrentGame() {
		return currentGame;
	}

	public void setCurrentGame(Game currentGame) {
		this.currentGame = currentGame;
	}

	/**
	 * What Color has the logedin User ?
	 * 
	 * @return
	 */
	public PlayerType getPlayerTypeOfUser() {
		if (logedinUser != null && currentGame != null) {
			if (logedinUser.getUsername().equals(
					currentGame.getNameYellowPlayer())) {
				return PlayerType.PLAYER_YELLOW;
			}
			if (logedinUser.getUsername()
					.equals(currentGame.getNameRedPlayer())) {
				return PlayerType.PLAYER_RED;
			}
			if (logedinUser.getUsername().equals(
					currentGame.getNameGreenPlayer())) {
				return PlayerType.PLAYER_GREEN;
			}
			if (logedinUser.getUsername().equals(
					currentGame.getNameBluePlayer())) {
				return PlayerType.PLAYER_BLUE;
			}
		}
		return null;
	}
}
